package com.chengyu.core.controller.pay;

import com.chengyu.core.component.OperationLog;
import com.chengyu.core.controller.ShopBaseController;
import com.chengyu.core.domain.form.PayBaseForm;
import com.chengyu.core.entity.CommonResult;
import com.chengyu.core.model.UmsShop;
import com.chengyu.core.service.goods.GoodsService;
import com.chengyu.core.service.member.MemberCouponService;
import com.chengyu.core.service.order.OrderGroupService;
import com.chengyu.core.service.order.OrderService;
import com.chengyu.core.service.pay.PayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Api(tags = "订单")
@Controller
@RequestMapping("/member")
public class ShoLevelPayController extends ShopBaseController {

	@Autowired
	private PayService payService;

	@OperationLog
	@ApiOperation(value = "支付订单")
	@ResponseBody
	@RequestMapping(value={"/shopLevel/pay"}, method=RequestMethod.POST)
	public CommonResult<Map<String,Object>> payOrder(String payOrderNo, PayBaseForm payBaseForm) throws Exception{
		Integer shopId = getCurrentShopId();
		UmsShop shop = getCurrentShop();
		super.validateRepeat("payOrder-"+shopId, 5000L, "点太快了~");
		//调用支付接口
		payBaseForm.setIp(this.getRequestIp());
		String message = payService.shopLevelPay(shop, payOrderNo, payBaseForm,"pc");

		Map<String,Object> result = new HashMap<>();
		result.put("payOrderNo", payOrderNo);
		result.put("message", message);
		return CommonResult.success(result);
	}


}